package org.shushan.cloud.transaction.sample.service;

import cn.hutool.core.bean.BeanUtil;
import org.shushan.cloud.transaction.sample.entity.UserEntity;
import org.shushan.framework.transaction.service.impl.AbstractTccTransactionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author zhigang.li
 * @date 2022/9/24
 * @email 2429967859@qq.com
 */
@Service
public class UserTccService extends AbstractTccTransactionService {

    @Autowired
    UserService userService;

    @Override
    public void doPrepare(Object params) {
        System.out.println(params);
        userService.save(BeanUtil.toBean(params, UserEntity.class));
        System.out.println(1111);
    }

    @Override
    public void doCommit(Object params) {
        System.out.println(params);
        System.out.println(2222);
    }

    @Override
    public void doRollback(Object params) {
        System.out.println(params);
        System.out.println(3333);
    }
}
